<?php
include ('include/authorize.php'); 
include 'charts.php';



$base_column=$_GET['base_column'];
$begin_date=$_GET['begin_date'];
$end_date=$_GET['end_date'];
$op=$_GET['op'];
$user_id=$_GET['user_id'];

    /*
     if($begin_date!='')
     {
      $filtru_mod=" and  date(date_modified) >= '".$begin_date." 00:00:00'  ";
      $filtru_add=" and  date(date_created) >= '".$begin_date." 00:00:00'  ";
      $filtru_del=" and  date(`date`) >= '".$begin_date." 00:00:00'  ";
      
     }
     if($end_date!='')
     {
      $filtru_mod.=" and  date(date_modified) <= '".$end_date." 59:59:59'  ";
      $filtru_add.=" and  date(date_created) <= '".$end_date." 59:59:59'  ";
      $filtru_del.=" and  date(`date`) <= '".$end_date." 59:59:59'  ";
     }*/
    ////////////////
    
    

     
     if (($begin_date!='')and($end_date!=''))
     {
      $filtru_mod=" and ( date(date_modified) >= '".$begin_date."' and date(date_modified) <= '".$end_date."' )  ";
      $filtru_add=" and ( date(date_created) >= '".$begin_date."' and date(date_created) <= '".$end_date."' )  ";
      
      $filtru_del=" and ( date(`date`) >= '".$begin_date."' and date(`date`) <= '".$end_date."' )  ";
      
      $filtru_tot=" and (( date(date_modified) >= '".$begin_date."' and date(date_modified) <= '".$end_date."' and modify_by='".$user_id."' ) or ( date(date_created) >= '".$begin_date."' and date(date_created) <= '".$end_date."' and create_by='".$user_id."' )) " ;
     }
     
     if(($begin_date!='')and($end_date==''))
     {
      $filtru_mod.=" and  date(date_modified) >= '".$begin_date."'  ";
      $filtru_add.=" and  date(date_created) >= '".$begin_date."'  "; 
           
      $filtru_del=" and ( date(`date`) >= '".$begin_date."'  )  ";      
      
      $filtru_tot=" and ( date(date_modified) >= '".$begin_date."'  or  date(date_created) >= '".$begin_date."'  ) " ;
     }
     
     if (($begin_date=='')and($end_date!=''))
     {
      $filtru_mod.=" and  date(date_modified) <= '".$end_date."'  ";
      $filtru_add.=" and  date(date_created) <= '".$end_date."'  ";
      $filtru_del=" and ( date(`date`) <= '".$end_date."' )  ";
      
      $filtru_tot=" and ( date(date_modified) <= '".$end_date."'  or  date(date_created) <= '".$end_date."'  ) " ;
     }
     
       
     // echo  "select * from persons where 1=1 $filtru_mod and modify_by='".$user_id."' ";
          
      $modificate=mysql_numrows(mysql_query("select * from persons where 1=1 $filtru_mod and modify_by='".$user_id."' ")) ;
       
      $create=mysql_numrows(mysql_query("select * from persons where 1=1  $filtru_add and create_by='".$user_id."' "));
      
      $sterse=mysql_numrows(mysql_query("select * from user_activity where operatie=2  $filtru_del and user_id='".$user_id."' "));
      
      $total=mysql_numrows(mysql_query("select * from persons where 1=1  $filtru_tot  "));


$nume=array('','Modificate','Adaugate','Sterse');
$total=array('',$modificate,$create,$sterse);
 
 

if ($_GET['proc']==0)
{
$chart[ 'axis_value' ] = array ( 'font'=>"arial", 'bold'=>true, 'size'=>10, 'color'=>"000000", 'alpha'=>100, 'steps'=>7, 'decimals'=>0, 'separator'=>"" );

$chart [ 'axis_category' ] = array ( "bold"=>true, 'orientation'   =>  "diagonal_up" , 'font' =>"Arial", 'size'   =>  12 ,
 'color'=>"000000");

$chart[ 'chart_border' ] = array ( 'color'=>"000000", 'top_thickness'=>1, 'bottom_thickness'=>2, 'left_thickness'=>0, 'right_thickness'=>0 );

$chart[ 'chart_grid_h' ] = array ( 'alpha'=>20, 'color'=>"000000", 'thickness'=>1, 'type'=>"dashed" );

$chart[ 'chart_rect' ] = array ( 'x'=>75, 'y'=>50, 'width'=>500, 'height'=> 350, 'positive_color'=>"B9B7B7", 'positive_alpha'=>100 );

$chart[ 'chart_transition' ] = array ( 'type'=>"scale", 'delay'=>.5, 'duration'=>.5, 'order'=>"series" );

$chart[ 'chart_value' ] = array ( 'color'=>"ffffff", 'alpha'=>100, 'font'=>"arial", 'bold'=>true, 'size'=>10, 'position'=>"middle",  'decimals'=>0, 'separator'=>"", 'as_percentage'=>false );

$chart [ 'chart_type' ] = "column";

$chart [ 'series_switch' ] = true;

$chart[ 'legend_rect' ] = array ( 'x'=>-1000, 'y'=>-1000, 'width'=>1, 'height'=>1, 'margin'=>1 ); 

$chart[ 'series_color' ] = array ("ddaa41", "88dd11", "4e62dd", "ff8811", "4d4d4d", "5a4b6e",'4ecc72','846e54','d9db4c','db714c' ,'4cdbd6','db4cd6','a04cdb'  ); 
$chart[ 'series_gap' ] = array ( 'set_gap'=>50 );

$chart[ 'chart_data' ] = array ( $nume , $total );

}

if ($_GET['proc']==1){



$chart[ 'chart_data' ] = array ( $nume , $total );

$chart[ 'chart_rect' ] = array ( 'positive_color'=>"000000", 'positive_alpha'=>0 );
$chart[ 'chart_type' ] = "pie";
$chart[ 'chart_value' ] = array ( 'color'=>"000000", 'alpha'=>100, 'font'=>"arial", 'bold'=>true, 'size'=>10, 'position'=>"inside", 'prefix'=>"", 'suffix'=>"", 'decimals'=>0, 'separator'=>"", 'as_percentage'=>true );


$chart[ 'legend_label' ] = array ( 'layout'=>"horizontal", 'bullet'=>"circle", 'font'=>"arial", 'bold'=>true, 'size'=>10, 'color'=>"000000", 'alpha'=>100  ); 

$chart[ 'legend_rect' ] = array ( 'fill_color'=>"ffffff", 'fill_alpha'=>0, 'line_color'=>"000000", 'line_alpha'=>0, 'line_thickness'=>1 ); 

$chart[ 'series_color' ] = array ("ddaa41", "88dd11", "4e62dd", "ff8811", "4d4d4d", "5a4b6e",'4ecc72','846e54','d9db4c','db714c' ,'4cdbd6','db4cd6','a04cdb'  ); 
//$chart[ 'series_explode' ] = array ( 20, 0, 50 );
}


SendChartData ( $chart );
?>